<template>
  <div class="search">
    <f-form ref="form" :action="api.report" :form-key="this.formItem.reportId">
      <f-form-item ref="supplierInfo" label="分包商" type="select" name="supplierId" :autoLoad="false"
                   :data="api.report.getBusProjectAllSupplier"
                   label-key="supplierName,supplierNum,restSupplierNum"
                   value-key="supplierId" :value="formItem.supplierId" :showSearch="true" @change="supplierChange"/>
      <f-form-item label="申报数量" name="declareQuantity" :value="formItem.declareQuantity"/>
      <f-form-item label="确认数量" name="confirmQuantity" :value="formItem.confirmQuantity"/>
      <f-form-item label="填报月份" name="reportMonth" type="month" :value="formItem.reportMonth"/>
    </f-form>
  </div>
</template>
<script>
  import api from './js/apiReport'

  export default {
    name: 'reportForm',
    props: {
      detailsParams: {}
    },
    data() {
      return {
        refs: this.$refs,
        api: Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem(),
        supplierList: [{ supplierLabel: '包商1', supplierId: 1 }, { supplierLabel: '包商2', supplierId: 2 }],
        reportMonth: ''
      }
    },
    methods: {
      getFormItem() {
        return {
          reportId: '',
          projectId: '',
          materialId: '',
          supplierId: '',
          declareQuantity: '',
          confirmQuantity: '',
          reportMonth: '',
          userId: '',
          createTime: '',
          updateTime: ''
        }
      },
      //表单赋值
      setData(data) {
        this.refs.supplierInfo.initData(this.detailsParams)
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.reportId) {
          let params = {
            reportId: data.reportId
          }
          this.refs['form'].getDetails(params, (data) => {
            this.formItem = data
            this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.detailsParams.handlerName = 'busReportSaveHandler'
        this.$refs.form.submit(this.detailsParams, callback)
      },
      supplierChange(value) {
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
